package com.chanceit.ssss.activity;

import org.gl.GlobalVariable;
import org.gl.customview.ViewPager;
import org.gl.utils.Tip;

import android.os.Bundle;

import com.chanceit.ssss.adapters.SectionsPagerAdapter;
import com.chanceit.ssss.common.IntentExtraDataKey;
import com.chanceit.ssss.fragments.ToDoOrderListFragment;
import com.chanceit.ssss.fragments.TodoComplaintListFragment;

public class TodoListActivity extends BaseFragmentActivity {
	SectionsPagerAdapter mSectionsPagerAdapter;
	ViewPager mViewPager;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_fragment_container);
		if (findViewById(R.id.fragment_container) != null) {
			// However, if we're being restored from a previous state,
			// then we don't need to do anything and should return or else
			// we could end up with overlapping fragments.
			if (savedInstanceState != null) {
				return;
			}
			switch (GlobalVariable.getGlobalInstance().intent.getIntExtra(
					IntentExtraDataKey.TODO_TYPE,
					IntentExtraDataKey.TODO_TYPE_UNKNOW)) {
			case IntentExtraDataKey.TODO_TYPE_ORDER:
				getSupportFragmentManager()
						.beginTransaction()
						.add(R.id.fragment_container,
								new ToDoOrderListFragment()).commit();
				break;
			case IntentExtraDataKey.TODO_TYPE_COM:
				getSupportFragmentManager()
						.beginTransaction()
						.add(R.id.fragment_container,
								new TodoComplaintListFragment()).commit();
				break;
			case IntentExtraDataKey.TODO_TYPE_UNKNOW:
			default:
				Tip.show("unknow todo type");
				break;
			}

		}
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		GlobalVariable.getGlobalInstance().intent.putExtra(
				IntentExtraDataKey.TODO_TYPE,
				IntentExtraDataKey.TODO_TYPE_UNKNOW);
	}
}
